<?php

function fnGetMasterSMS() {
    $results = mysql_query("SELECT * FROM LST_KETERANGAN_SMS");
    return $results;
}

function fnGetReportSMS() {
    $results = mysql_query("SELECT * FROM V_SMS_OUTBOX3
                            ORDER BY ID");
    return $results;
}

function fnGetReportSMSByKodeTujuan($kode) {
    $results = mysql_query("SELECT * FROM V_SMS_OUTBOX3 
                            WHERE trim(kode_sms) = trim('$kode')
                            ORDER BY ID");
    return $results;
}

function fnGetReportSMSByAlasan($alasan) {
    $results = mysql_query("SELECT * FROM V_SMS_OUTBOX3 
                            WHERE trim(alasan_sms) = trim('$alasan')
                            ORDER BY ID");
    return $results;
}

function fnGetReportSMSByPengirim($nama) {
    $results = mysql_query("SELECT * FROM V_SMS_OUTBOX3  
                            WHERE trim(pengirim) = trim('$nama')
                            ORDER BY ID");
    return $results;
}

function fnGetReportSMSByAll($tujuan, $pengirim, $tema) {
    $query = "SELECT * FROM V_SMS_OUTBOX3 WHERE 1=1";
    if ($tujuan <> '0') {
        $queryTujuan = "AND trim(kode_sms) = trim('$tujuan')";
        $query = $query.' '.$queryTujuan;
    }
    if ($pengirim <> '0') {
        $queryPengirim = "AND trim(kode_pengirim) = trim('$pengirim')";
        $query = $query.' '.$queryPengirim;
    }
    if ($tema <> '0') {
        $queryTema = "AND trim(alasan_sms) = trim('$tema')";
        $query = $query.' '.$queryTema;
    }
    //echo '$query: '.$query;
    $results = mysql_query($query.' '."ORDER BY ID");
    return $results;
}
?>
